package org.leaf.pethome.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@Configuration
public class Swagger3Config {
    private ApiInfo apiInfo(){
        return new ApiInfo(
                "swagger3 api for module user",
                "user module for TCM version 1.0",
                "version 1.0",
                "/user",
                new Contact("叶域","/user","12665473@qq.com"),
                "Apache-2.0",
                "http://www.apache.com",
                new ArrayList<>()
        );
    }

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .groupName("吴彦组")
                .host("localhost")
                .pathMapping("http://localhost:8080")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ybg.user.controller"))
                .paths(path -> path.matches("(/admin)?/user(/.+)*"))
                .build();
    }
}
